<template>
  <div>
    <div>
      <ele-page
        v-loading="loading"
        :formConfig="searchDialog"
        ref="eleTable"
        @handleOperateEvent="handleOperateEvent"
        :operateList="operateList"
        :column="column"
        :getList="getReworkVos"
        uniqueId="mesTeamTable"
      >
      </ele-page>
      <el-drawer
        :visible.sync="visible"
        :wrapperClosable="false"
        :isShowBackBtn="false"
        :isShowSubmitBtn="false"
        :isShowCancelBtn="false"
        size="95%"
        top="4vh"
        :append-to-body="true"
        :close-on-click-modal="false"
      >
        <div
          style="
        margin-top:10px;
        margin-left :10px;
        margin-right:10px;
        bottom :10px;
        "
        >
          <el-form ref="form" :model="detailData" label-width="110px">
            <el-row>
              <el-col :span="24">
                    <div >
                      <span>返工明细</span>
                    </div>
                    <el-table
                      :data="detailData"
                      border
                      style="width: 100%">
                      <el-table-column
                        type="index"
                        label="序号"
                        min-width="50"
                      />
                      <el-table-column
                        prop="preparationOrderCode"
                        label="整备工单号"
                        min-width="150">
                      </el-table-column>
                      <el-table-column
                        prop="repairTypeName"
                        label="工种"
                        min-width="80">
                      </el-table-column>
                      <el-table-column
                        prop="partSystem"
                        label="系统"
                        min-width="80">
                      </el-table-column>
                      <el-table-column
                        prop="partGroup"
                        label="分组"
                        min-width="60">
                      </el-table-column>
                      <el-table-column
                        prop="partsName"
                        label="部件"
                        min-width="120">
                      </el-table-column>
                      <el-table-column
                        prop="orderName"
                        label="整备项"
                        min-width="120">
                      </el-table-column>
                      <el-table-column
                        prop="startTime"
                        label="返工开始时间"
                        min-width="120">
                      </el-table-column>
                      <el-table-column
                        prop="endTime"
                        label="返工结束时间"
                        min-width="120">
                      </el-table-column>
                      <el-table-column
                        prop="startByName"
                        label="返工工程师"
                        min-width="120">
                      </el-table-column>
                      <el-table-column
                        prop="approvalName"
                        label="审批人"
                        min-width="120">
                      </el-table-column>
                      <el-table-column
                        prop="orderSource"
                        label="返工来源"
                        min-width="120">
                        <template slot-scope="scope">
                            <span>
                              {{orderSource(scope.row.orderSource)}}
                            </span>
                        </template>
                      </el-table-column>
                      <el-table-column
                        prop="evolve"
                        label="返工进展"
                        min-width="75">
                        <template slot-scope="scope">
                            <span>
                              {{evolve(scope.row.evolve)}}
                            </span>
                        </template>
                      </el-table-column>
                    </el-table>
              </el-col>
            </el-row>
          </el-form>
        </div>
      </el-drawer>
    </div>
    <!-- 此组件放到与抽屉平级，理论上不需要修改 -->
  </div>
</template>

<script>
import {
  searchConfig,
  rowConfig,

  operateList, evolve, orderSource, exportExlUrl
} from './config'
const { adminUrl } = url();


import url from "@/axios/url";
import {getPreparationReworkList, getReworkVos} from "@/api/reportForms/reportForms";
import {exportExcel} from "@/utils/judge";

export default {
  name: 'reworkDetailed',
  mixins: [ searchConfig],
  data() {
    const self = this
    return {
      fileList: [],
      fileListOrg: [],
      isHaveCj:true,
      adminUrl: adminUrl,
      operateList,
      visible: false,
      isLoading: false,
      loading: false,
      imgUrlList:[],
      mainImgUrl:'',
      subImgUrl:'',
      dataId:'',
      subType:0,
      detailData: {},
      subId: '',
      dialogVisible: false,
      subPicViewdialogVisible: false,
      mainPicUpdateDialogVisible: false,
      subPicUpdateDialogVisible: false,
      getReworkVos,
      // 列表页字段的绑定配置
      column: [
        {
          type: 'selection',
          fixed: 'left'
        },
        {
          type: 'index',
          label: $i18n.t('common.order'),
          width: 60,
          fixed: 'left'
        },
        {
          prop: 'modelName',
          label: '车型',
          showOverflowTooltip: true
        },
        {
          prop: 'vinCode',
          label: 'VIN码',
          showOverflowTooltip: true,
          minWidth: 120,
        },
        {
          prop: 'uwbCode',
          label: 'UWB码',
          showOverflowTooltip: true,
          minWidth: 50,
        },
        {
          prop: 'allReworkCount',
          label: '总返工数量',
          minWidth: 100,
          showOverflowTooltip: true
        },
        {
          prop: 'allReworkTime',
          label: '总返工耗时',
          minWidth: 80,
          showOverflowTooltip: true
        },
        {
          prop: 'preparationReworkCount',
          label: '整备返工数量',
        },
        {
          prop: 'preparationReworkTime',
          label: '整备返工耗时',
          showOverflowTooltip: true
        },
        {
          prop: 'finalReworkCount',
          label: '终检返工数量',
          showOverflowTooltip: true
        },
        {
          prop: 'finalReworkTime',
          label: '终检返工耗时',
        },
        {
          prop: 'operate',
          label: $i18n.t('common.operation'),
          width: 160,
          fixed: 'right',
          render: (h, scope) => {
            return <ele-row-operation scope={scope} rowConfig={rowConfig} onRowOperate={this.rowOperate} />
          }
        }
      ],
      form:{}
    }
  },
  computed: {},
  methods: {
    getData()
    {
      getPreparationReworkList(this.dataId).then(res => {
        this.detailData = res.data.result
        console.log(res.data.result,'什么玩意')
      })
    },
    evolve,orderSource,

    // 表格顶部按钮操作事件
    // 表格行操作事件
    rowOperate({ handleName, name, row }) {
      const fnc = {
        view: () => {
          this.dataId = row.id;
          this.getData();
          this.visible = true
        },
        exportExl: () => {
          exportExcel(exportExlUrl + row.id)
        },
      }
      fnc[handleName]()
    },
    // 刷新表格数据
    refresh(isReset = true) {
      this.$refs.eleTable.refresh(isReset)
    },
    handleOperateEvent(data) {
      this.title = data.name;
      const { codeStrategy } = this.formDataDialog;
      const fnc = {
        exportExcel: () => {
          // window.open(
          //   "http://9000.gr817115.m6tfe15g.ceb51d.grapps.cn/file-template/销售订单模板.zip"
          // );
          var urlexportExcel = `${minioUrl}/mes-template/班组导入模板.xlsx`;
          console.log("aaaaaaa=", urlexportExcel);
          window.open(urlexportExcel);
        },
      };
      fnc[data.handleName]();
    },

  }
}
</script>
<style lang="scss" scoped>
.el-row {
  margin-top: 20px;
}
.el-row.last-child {
  margin-bottom: 0;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  display: flex;
  justify-content: center;
  min-height: 25px;
}

//:deep(.ele-form-search){
//  height: 100px !important;
//}
</style>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  min-width: 178px;
  min-height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  min-width: 178px;
  min-height: 178px;
  display: block;
}
input:disabled{
  opacity: 1;
  -webkit-text-fill-color: black;
}
</style>
